package com.hontlong.aixue.tiles.viewpreparer;

import org.apache.tiles.Attribute;
import org.apache.tiles.AttributeContext;
import org.apache.tiles.context.TilesRequestContext;
import org.apache.tiles.preparer.ViewPreparerSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hontlong.aixue.bean.User;
import com.hontlong.aixue.service.UserService;

@Service
public class UserAboutPreparer extends ViewPreparerSupport {
	@Autowired
	private UserService userService;

	@Override
	public void execute(TilesRequestContext tilesContext,
			AttributeContext attributeContext) {
		User user = userService.getCurrentUser();
		if (user == null) {
			return;
		}
		attributeContext.putAttribute("user", new Attribute(user));
	}
}
